/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MainPackage;

import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author n.kaminski
 */
public class UserReferenzwerte {
    
    private User user;
    //Energietraeger
    private double kcal,Broteinheiten,Kohlenhydrate,Eiweiss_g,Cholesterin_mg, Fett_g, UngesFS_g;

    //Mineralstoffe
    private double Natrium_mg, Kalium_mg, Magnesium_mg, Calcium_mg, Phosphor_mg, Eisen_mg, Zink_mg;
    
    //Vitamine
    private double Vitamin_A_mueg, Vitamin_B1_mg, Vitamin_B2_mg, Vitamin_B6_mg, Vitamin_C_mg, Vitamin_E_mg, Folsaeure_mueg, Carotin_mg;
 
    public UserReferenzwerte(User pUser){
        user = pUser;
        berechnen();
    }
    
    public void berechnen(){
        boolean m = user.getGeschlecht() == User.Geschlecht.maennlich;
        int alter = user.getAlter();
        //<editor-fold defaultstate="collapsed" desc="KCAL">
        if(user.getArbeit() == User.Arbeit.vornehmlichSitzen){
            if(alter >= 65){
                kcal = (m) ? 2000 : 1600;
            }else if(alter >= 51){
                kcal = (m) ? 2200 : 1800;
            }else if(alter >= 25){
                kcal = (m) ? 2400 : 1900;
            }else if(alter >= 19){
                kcal = (m) ? 2500 : 1900;
            }else{
                kcal = (m) ? 2500 : 2000;
            }            
        }else if(user.getArbeit() == User.Arbeit.vornehmlichStehend){
            if(alter >= 65){
                kcal = (m) ? 2300 : 1800;
            }else if(alter >= 51){
                kcal = (m) ? 2500 : 2000;
            }else if(alter >= 25){
                kcal = (m) ? 2800 : 2100;
            }else if(alter >= 19){
                kcal = (m) ? 2900 : 2200;
            }else{
                kcal = (m) ? 2900 : 2300;
            }            
        }else{
            if(alter >= 65){
                kcal = (m) ? 2500 : 2100;
            }else if(alter >= 51){
                kcal = (m) ? 2800 : 2300;
            }else if(alter >= 25){
                kcal = (m) ? 3100 : 2400;
            }else if(alter >= 19){
                kcal = (m) ? 3300 : 2500;
            }else{
                kcal = (m) ? 3300 : 2600;
            }            
        }
        //</editor-fold>
        
        this.Broteinheiten = 17;
        
        //<editor-fold defaultstate="collapsed" desc="Kohlenhydrate">
        Kohlenhydrate = ((kcal*0.55)/4.0);
        Eiweiss_g = ((kcal*0.15)/4.0);
        Fett_g = ((kcal*0.3)/9.0);        
        Cholesterin_mg = 300;
        UngesFS_g = 10;
        
        Natrium_mg = 550;
        Kalium_mg = 2000;
        Vitamin_C_mg = 100;
        Folsaeure_mueg = 400;
        if(alter >= 65){
            Magnesium_mg = (m) ? 350 : 300;
            Calcium_mg = 1000;
            Phosphor_mg = 700;
            Eisen_mg = 10;
            
            Vitamin_A_mueg = (m) ? 1000 : 800;
            Vitamin_B1_mg = 1;
            Vitamin_B2_mg = 1.2;
            Vitamin_B6_mg = (m) ? 1.4 : 1.2;
            Vitamin_E_mg = 12;
        }else if(alter >= 51){
            Magnesium_mg = (m) ? 350 : 300;
            Calcium_mg = 1000;
            Phosphor_mg = 700;
            Eisen_mg = 10;
            
            Vitamin_A_mueg = (m) ? 1000 : 800;
            Vitamin_B1_mg = (m) ? 1.1 : 1;
            Vitamin_B2_mg = (m) ? 1.3 : 1.2;
            Vitamin_B6_mg = (m) ? 1.5 : 1.2;
            Vitamin_E_mg = 13;
        }else if(alter >= 25){
            Magnesium_mg = (m) ? 350 : 300;
            Calcium_mg = 1000;
            Phosphor_mg = 700;
            Eisen_mg = (m) ? 10 : 15;
            
            Vitamin_A_mueg = (m) ? 1000 : 800;
            Vitamin_B1_mg = (m) ? 1.2 : 1;
            Vitamin_B2_mg = (m) ? 1.4 : 1.2;
            Vitamin_B6_mg = (m) ? 1.5 : 1.2;
            Vitamin_E_mg = 14;
        }else if(alter >= 19){
            Magnesium_mg = (m) ? 400 : 310;
            Calcium_mg = 1000;
            Phosphor_mg = 700;
            Eisen_mg = (m) ? 10 : 15;     
            
            Vitamin_A_mueg = (m) ? 1000 : 800;
            Vitamin_B1_mg = (m) ? 1.3 : 1;
            Vitamin_B2_mg = (m) ? 1.5 : 1.2;
            Vitamin_B6_mg = (m) ? 1.5 : 1.2;
            Vitamin_E_mg = 15;
        }else{
            Magnesium_mg = (m) ? 400 : 350;
            Calcium_mg = 1200;
            Phosphor_mg = 1250;
            Eisen_mg = (m) ? 12 : 15;
            
            Vitamin_A_mueg = (m) ? 1100 : 900;
            Vitamin_B1_mg = (m) ? 1.3 : 1;
            Vitamin_B2_mg = (m) ? 1.5 : 1.2;
            Vitamin_B6_mg = (m) ? 1.6 : 1.2;
            Vitamin_E_mg = 15;
        } 
        Carotin_mg = Vitamin_A_mueg / 1000.0 *6;
        Zink_mg = (m) ? 10 : 7;
        
    }
    
    
    public void FillJTable(JTable table){
        String[] ColNames = {"Inhaltsstoff", "Wert"};
        DefaultTableModel dtm = new DefaultTableModel(ColNames, 25);
      
        
        dtm.setValueAt("Kilo Kalorien (kcal)", 1, 0);
        dtm.setValueAt(kcal, 1, 1);
        dtm.setValueAt("Kohlenhydrate", 3, 0);
        dtm.setValueAt(Kohlenhydrate, 3, 1);
        dtm.setValueAt("Eiweiß (g)", 4, 0);
        dtm.setValueAt(Eiweiss_g, 4, 1);
        dtm.setValueAt("Cholesterin (mg)", 5, 0);
        dtm.setValueAt(Cholesterin_mg, 5, 1);
        dtm.setValueAt("Fett (g)", 6, 0);
        dtm.setValueAt(Fett_g, 6, 1);
        dtm.setValueAt("mehrf. unges. FS (g)", 7, 0);
        dtm.setValueAt(UngesFS_g, 7, 1);
        
        dtm.setValueAt("Natrium (mg)", 9, 0);
        dtm.setValueAt(Natrium_mg, 9, 1);
        dtm.setValueAt("Kalium (mg)", 10, 0);
        dtm.setValueAt(Kalium_mg, 10, 1);
        dtm.setValueAt("Magnesium (mg)", 11, 0);
        dtm.setValueAt(Magnesium_mg, 11, 1);
        dtm.setValueAt("Calcium (mg)", 12, 0);
        dtm.setValueAt(Calcium_mg, 12, 1);
        dtm.setValueAt("Phosphor (mg)", 13, 0);
        dtm.setValueAt(Phosphor_mg, 13, 1);
        dtm.setValueAt("Eisen (mg)", 14, 0);
        dtm.setValueAt(Eisen_mg, 14, 1);
        dtm.setValueAt("Zink (mg)", 15, 0);
        dtm.setValueAt(Zink_mg, 15, 1);
        
        dtm.setValueAt("Vitamin A (µg)", 17, 0);
        dtm.setValueAt(Vitamin_A_mueg, 17, 1);
        dtm.setValueAt("Vitamin B1 (mg)", 18, 0);
        dtm.setValueAt(Vitamin_B1_mg, 18, 1);
        dtm.setValueAt("Vitamin B2 (mg)", 19, 0);
        dtm.setValueAt(Vitamin_B2_mg, 19, 1);
        dtm.setValueAt("Vitamin B6 (mg)", 20, 0);
        dtm.setValueAt(Vitamin_B6_mg, 20, 1);
        dtm.setValueAt("Vitamin C (mg)", 21, 0);
        dtm.setValueAt(Vitamin_C_mg, 21, 1);
        dtm.setValueAt("Vitamin E (mg)", 22, 0);
        dtm.setValueAt(Vitamin_E_mg, 22, 1);
        dtm.setValueAt("Folsäure (µg)", 23, 0);
        dtm.setValueAt(Folsaeure_mueg, 23, 1);
        dtm.setValueAt("Carotin (mg)", 24, 0);
        dtm.setValueAt(Carotin_mg, 24, 1);
        
        table.setModel(dtm);
    }
    
     //<editor-fold defaultstate="collapsed" desc="Getter & Setter für Attribute">
    public double getKcal(){
        return this.kcal;
    }
    public void setKcal(double kcal){
        this.kcal = kcal;
    }
    public double getBroteinheiten(){
        return this.Broteinheiten;
    }
    public void setBroteinheiten(double Broteinheiten){
        this.Broteinheiten = Broteinheiten;
    }
    public double getKohlenhydrate(){
        return this.Kohlenhydrate;
    }
    public void setKohlenhydrate(double Kohlenhydrate){
        this.Kohlenhydrate = Kohlenhydrate;
    }
    public double getEiweiss_g(){
        return this.Eiweiss_g;
    }
    public void setEiweiss_g(double Eiweiss_g){
        this.Eiweiss_g = Eiweiss_g;
    }
    public double getCholesterin_mg(){
        return this.Cholesterin_mg;
    }
    public void setCholesterin_mg(double Cholesterin_mg){
        this.Cholesterin_mg = Cholesterin_mg;
    }
    public double getFett_g(){
        return this.Fett_g;
    }
    public void setFett_g(double Fett_g){
        this.Fett_g = Fett_g;
    }
    public double getUngesFS_g(){
        return this.UngesFS_g;
    }
    public void setUngesFS_g(double UngesFS_g){
        this.UngesFS_g = UngesFS_g;
    }
    public double getNatrium_mg(){
        return this.Natrium_mg;
    }
    public void setNatrium_mg(double Natrium_mg){
        this.Natrium_mg = Natrium_mg;
    }
    public double getKalium_mg(){
        return this.Kalium_mg;
    }
    public void setKalium_mg(double Kalium_mg){
        this.Kalium_mg = Kalium_mg;
    }
    public double getMagnesium_mg(){
        return this.Magnesium_mg;
    }
    public void setMagnesium_mg(double Magnesium_mg){
        this.Magnesium_mg = Magnesium_mg;
    }
    public double getCalcium_mg(){
        return this.Calcium_mg;
    }
    public void setCalcium_mg(double Calcium_mg){
        this.Calcium_mg = Calcium_mg;
    }
    public double getPhosphor_mg(){
        return this.Phosphor_mg;
    }
    public void setPhosphor_mg(double Phosphor_mg){
        this.Phosphor_mg = Phosphor_mg;
    }
    public double getEisen_mg(){
        return this.Eisen_mg;
    }
    public void setEisen_mg(double Eisen_mg){
        this.Eisen_mg = Eisen_mg;
    }
    public double getZink_mg(){
        return this.Zink_mg;
    }
    public void setZink_mg(double Zink_mg){
        this.Zink_mg = Zink_mg;
    }    
    public double getVitamin_A_mueg(){
        return this.Vitamin_A_mueg;
    }
    public void setVitamin_A_mueg(double Vitamin_A_mueg){
        this.Vitamin_A_mueg = Vitamin_A_mueg;
    }
    public double getVitamin_B1_mg(){
        return this.Vitamin_B1_mg;
    }
    public void setVitamin_B1_mg(double Vitamin_B1_mg){
        this.Vitamin_B1_mg = Vitamin_B1_mg;
    }
    public double getVitamin_B2_mg(){
        return this.Vitamin_B2_mg;
    }
    public void setVitamin_B2_mg(double Vitamin_B2_mg){
        this.Vitamin_B2_mg = Vitamin_B2_mg;
    }
    public double getVitamin_B6_mg(){
        return this.Vitamin_B6_mg;
    }
    public void setVitamin_B6_mg(double Vitamin_B6_mg){
        this.Vitamin_B6_mg = Vitamin_B6_mg;
    }
    public double getVitamin_C_mg(){
        return this.Vitamin_C_mg;
    }
    public void setVitamin_C_mg(double Vitamin_C_mg){
        this.Vitamin_C_mg = Vitamin_C_mg;
    }
    public double getVitamin_E_mg(){
        return this.Vitamin_E_mg;
    }
    public void setVitamin_E_mg(double Vitamin_E_mg){
        this.Vitamin_E_mg = Vitamin_E_mg;
    }
    public double getFolsaeure_mueg(){
        return this.Folsaeure_mueg;
    }
    public void setFolsaeure_mueg(double Folsaeure_mueg){
        this.Folsaeure_mueg = Folsaeure_mueg;
    }
    public double getCarotin_mg(){
        return this.Carotin_mg;
    }
    public void setCarotin_mg(double Carotin_mg){
        this.Carotin_mg = Carotin_mg;
    }
    //</editor-fold>

}
